-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: deduplicate group min/max #40584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REF: deduplicate group min/max #40584
Conversation
group_min_or_max[lab, j] = val | ||
else: | ||
if val < group_min_or_max[lab, j]: | ||
group_min_or_max[lab, j] = val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to be able to do something like if PyObject_RichCompareBool(val, ..., cmp_method): ...
to simplify the conditional logic, but couldn't find a way to do something like this in Cython without the GIL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a perf impact here? its checking compute_max at each step in a nested loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see any perf impact based on ASVs above. For a loop invariant like compute_max
, I'd guess this check is optimized away by the compiler. (It could also just be negligible compared to the cost of the indexing operations)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense. worth it to de-duplicate a bunch of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. @jbrockmendel if any comments
LGTM |
thanks @mzeitlin11 |
ASVs look unaffected: